﻿USE [ASPNETVN.PORTAL]
GO
/****** Object:  Table [dbo].[t_FE_Attachments]    Script Date: 06/19/2008 15:39:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[t_FE_Attachments](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[PackageID] [int] NOT NULL,
	[OriginalFileName] [nvarchar](256) NOT NULL,
	[FileName] [nvarchar](256) NOT NULL,
	[FileSize] [bigint] NOT NULL,
	[FileType] [varchar](8) NOT NULL,
	[TotalDownloads] [int] NOT NULL CONSTRAINT [DF_t_FE_Attachs_Attach_Downloads]  DEFAULT ((0)),
	[Url] [nvarchar](512) NOT NULL,
 CONSTRAINT [PK_t_FE_Attachs] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[t_FE_Categories]    Script Date: 06/19/2008 15:39:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[t_FE_Categories](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[ModuleID] [int] NOT NULL,
	[ParentID] [int] NULL CONSTRAINT [DF_t_FE_Categories_ParentID]  DEFAULT ((0)),
	[Name] [nvarchar](128) NOT NULL,
 CONSTRAINT [PK_t_FE_Categories] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[t_FE_Comments]    Script Date: 06/19/2008 15:39:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[t_FE_Comments](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[PackageID] [int] NOT NULL,
	[Content] [ntext] NOT NULL,
	[CreatedBy] [nvarchar](128) NOT NULL,
	[CreationTime] [datetime] NOT NULL,
 CONSTRAINT [PK_t_FE_Comments] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[t_FE_PackageDetails]    Script Date: 06/19/2008 15:39:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[t_FE_PackageDetails](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[PackageID] [int] NOT NULL,
	[UserID] [int] NOT NULL,
 CONSTRAINT [PK_t_FE_PackageDetails] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[t_FE_Packages]    Script Date: 06/19/2008 15:39:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[t_FE_Packages](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[CategoryID] [int] NOT NULL,
	[Title] [nvarchar](512) NOT NULL,
	[Description] [ntext] NULL,
	[CreatedBy] [nvarchar](128) NOT NULL,
	[CreationTime] [datetime] NOT NULL CONSTRAINT [DF_t_FE_Packages_Package_CreatedDate]  DEFAULT (getdate()),
	[IsPublic] [bit] NOT NULL CONSTRAINT [DF_t_FE_Packages_Package_IsPublic]  DEFAULT ((0)),
 CONSTRAINT [PK_t_FE_Packages] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
ALTER TABLE [dbo].[t_FE_Attachments]  WITH CHECK ADD  CONSTRAINT [FK_t_FE_Attachments_t_FE_Packages] FOREIGN KEY([PackageID])
REFERENCES [dbo].[t_FE_Packages] ([ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[t_FE_Attachments] CHECK CONSTRAINT [FK_t_FE_Attachments_t_FE_Packages]
GO
ALTER TABLE [dbo].[t_FE_Comments]  WITH NOCHECK ADD  CONSTRAINT [FK_t_FE_Comments_t_FE_Packages] FOREIGN KEY([PackageID])
REFERENCES [dbo].[t_FE_Packages] ([ID])
ON UPDATE CASCADE
GO
ALTER TABLE [dbo].[t_FE_Comments] CHECK CONSTRAINT [FK_t_FE_Comments_t_FE_Packages]
GO
ALTER TABLE [dbo].[t_FE_PackageDetails]  WITH CHECK ADD  CONSTRAINT [FK_t_FE_PackageDetails_t_FE_Packages] FOREIGN KEY([PackageID])
REFERENCES [dbo].[t_FE_Packages] ([ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[t_FE_PackageDetails] CHECK CONSTRAINT [FK_t_FE_PackageDetails_t_FE_Packages]
GO
ALTER TABLE [dbo].[t_FE_PackageDetails]  WITH CHECK ADD  CONSTRAINT [FK_t_FE_PackageDetails_t_SYSTEM_Users] FOREIGN KEY([UserID])
REFERENCES [dbo].[t_SYSTEM_Users] ([ID])
GO
ALTER TABLE [dbo].[t_FE_PackageDetails] CHECK CONSTRAINT [FK_t_FE_PackageDetails_t_SYSTEM_Users]
GO
ALTER TABLE [dbo].[t_FE_Packages]  WITH CHECK ADD  CONSTRAINT [FK_t_FE_Packages_t_FE_Categories] FOREIGN KEY([CategoryID])
REFERENCES [dbo].[t_FE_Categories] ([ID])
ON UPDATE CASCADE
GO
ALTER TABLE [dbo].[t_FE_Packages] CHECK CONSTRAINT [FK_t_FE_Packages_t_FE_Categories]